const request = require('@utils/requst');
const { get } = require('@utils/wxapi');
const mop = '/mop/api';
const scope = 'mop';

class api {
  //商家登录
  static moplogin(data) {
    return request(mop, { scope, cmdCode: 'MCH_MEMBER_POST', source: JSON.stringify(data) });
  }
  //商品类型创建
  static newtype(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_CAT_POST',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //商品类型列表
  static typelist(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_CAT_LIST',
      mchId: get('mchId'),
      pageIndex: data.page,
      pageSize: data.size,
    });
  }
  //商品类型详情
  static typeget(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_CAT_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //商品类型修改
  static typeput(data) {
    return request(mop, {
      scope,
      token: get('token'),
      mchId: get('mchId'),
      cmdCode: 'GOODS_CAT_PATCH',
      source: JSON.stringify(data),
    });
  }
  //商品类型删除
  static typedel(data) {
    return request(mop, {
      scope,
      token: get('token'),
      mchId: get('mchId'),
      cmdCode: 'GOODS_CAT_DEL',
      source: JSON.stringify(data),
    });
  }
  //商品列表
  static goodList(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_LIST',
      mchId: get('mchId'),
      pageIndex: data.page,
      pageSize: data.size,
      source: JSON.stringify(data.data),
    });
  }
  //商品详情
  static goodGet(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //商品修改
  static goodPut(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_PATCH',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //商品删除
  static goodDel(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_DEL',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //商品上下架
  static goodsta(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_PATCH',
      mchId: get('mchId'),
      reqCode: 'UPDATE_STATUS',
      source: JSON.stringify(data),
    });
  }
  //商品添加
  static goodpost(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'GOODS_POST',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //用户列表
  static viplist(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MEMBER_LIST',
      mchId: get('mchId'),
      pageIndex: data.page,
      pageSize: data.size,
      source: "{'isVip':1}",
    });
  }
  //用户详情
  static vipget(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MEMBER_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //修改用户状态
  static vipPut(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MEMBER_PATCH',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //充值积分
  static give_points(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'PAY_PAYMENT_POST',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //订单列表
  static orderlist(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'ORDERS_LIST',
      mchId: get('mchId'),
      pageIndex: data.page,
      pageSize: data.size,
      source: JSON.stringify(data.data),
    });
  }
  //订单详情
  static orderget(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'ORDERS_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //订单修改
  static orderput(data) {
    return request(mop, {
      scope,
      cmdCode: 'ORDERS_PATCH',
      mchId: get('mchId'),
      source: JSON.stringify(data),
      token: get('token'),
    });
  }
  //餐桌列表
  static board_list(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MCH_DESK_LIST',
      mchId: get('mchId'),
      pageIndex: data.page,
      pageSize: data.size,
    });
  }
  //餐桌详情
  static board_get(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MCH_DESK_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //餐桌修改
  static board_put(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MCH_DESK_PATCH',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //餐桌新增
  static board_post(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MCH_DESK_POST',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //餐桌删除
  static board_del(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'MCH_DESK_DEL',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //日营收
  static daydata(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'STAT_MCH_DAY_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //月营收
  static monthdata(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'STAT_MCH_MONTH_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //年营收
  static yeardata(data) {
    return request(mop, {
      scope,
      token: get('token'),
      cmdCode: 'STAT_MCH_YEAR_GET',
      mchId: get('mchId'),
      source: JSON.stringify(data),
    });
  }
  //会员积分流水
  static moppoints(data) {
    return request(mop, {
      scope,
      cmdCode: 'MEMBER_FINANCE_LOG_LIST',
      mchId: get('mchId'),
      token: get('token'),
      pageIndex: data.page,
      pageSize: data.size,
    });
  }
  //充值活动列表
  static payhdList(data) {
    return request(mop, {
      scope,
      cmdCode: 'MKT_POINTS_LIST',
      mchId: get('mchId'),
      pageIndex: data.page,
      pageSize: data.size,
      token: get('token'),
    });
  }
  //充值活动详情
  static payhdGet(data) {
    return request(mop, {
      scope,
      cmdCode: 'MKT_POINTS_GET',
      source: JSON.stringify(data),
      mchId: get('mchId'),
      token: get('token'),
    });
  }
  //修改充值活动状态
  static paystaput(data) {
    return request(mop, {
      scope,
      cmdCode: 'MKT_POINTS_PATCH',
      mchId: get('mchId'),
      reqCode: 'UPDATE_STATUS',
      source: JSON.stringify(data),
      token: get('token'),
    });
  }
  //修改充值活动
  static payhdput(data) {
    return request(mop, {
      scope,
      cmdCode: 'MKT_POINTS_PATCH',
      mchId: get('mchId'),
      source: JSON.stringify(data),
      token: get('token'),
    });
  }
  //删除充值活动
  static payhdDel(data) {
    return request(mop, {
      scope,
      cmdCode: 'MKT_POINTS_DEL',
      mchId: get('mchId'),
      source: JSON.stringify(data),
      token: get('token'),
    });
  }
  //充值活动新增
  static payhdpost(data) {
    return request(mop, {
      scope,
      cmdCode: 'MKT_POINTS_POST',
      reqCode: 'UPDATE_STATUS',
      mchId: get('mchId'),
      token: get('token'),
      source: JSON.stringify(data),
    });
  }
  //退款列表
  static payrefundList(data) {
    return request(mop, {
      scope,
      cmdCode: 'ORDERS_RETURN_LIST',
      mchId: get('mchId'),
      token: get('token'),
      pageIndex: data.page,
      pageSize: data.size,
      source: JSON.stringify(data.data),
    });
  }
  //退款审核
  static payrefund(data) {
    return request(mop, {
      scope,
      cmdCode: 'ORDERS_RETURN_PATCH',
      mchId: get('mchId'),
      token: get('token'),
      reqCode: 'RETURN_ORDERS_AUDIT',
      source: JSON.stringify(data),
    });
  }
}

module.exports = api;
